package com.zhentao.device.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhentao.pojo.DeviceInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 设备信息Mapper
 */
@Mapper
public interface WaDeviceInfoMapper extends BaseMapper<DeviceInfo> {

    /**
     * 根据设备ID获取设备信息
     */
    @Select("SELECT * FROM device_info WHERE device_id = #{deviceId}")
    DeviceInfo selectByDeviceId(Long deviceId);

    /**
     * 获取所有在线设备
     */
    @Select("SELECT * FROM device_info WHERE status = 1 ORDER BY create_time DESC")
    List<DeviceInfo> selectOnlineDevices();

    /**
     * 获取所有设备（用于相关设备显示）
     */
    @Select("SELECT * FROM device_info ORDER BY create_time DESC LIMIT 10")
    List<DeviceInfo> selectAllDevices();

    /**
     * 根据设备编码获取设备信息
     */
    @Select("SELECT * FROM device_info WHERE device_code = #{deviceCode}")
    DeviceInfo selectByDeviceCode(String deviceCode);
}
